<!--#include file="common/header.html"-->
<body>
    <div class="container-fluid larry-wrapper">
        <div class="row">
            <div class="col-xs-12 col-sm-12 col-md-12">
                <!--头部搜索-->
                <section class="panel panel-padding">
                    <form class="layui-form" action="/education/admin/route">
                        <div class="layui-form">
                            <div class="layui-inline">
                                <div class="layui-input-inline">
                                    <input class="layui-input" name="_query.keyword" placeholder="关键字">
                                </div>
                            </div>
                            <div class="layui-inline">
                                <button lay-submit class="layui-btn" lay-filter="search">查找</button>
                            </div>
                        </div>
                    </form>
                </section>

                <!--列表-->
                <section class="panel panel-padding">
                    <div class="group-button">
                        <!--<button class="layui-btn layui-btn-small modal-catch" beforeFun="beforeAdd"
                                data-params='{"content":".add-subcat", "title":"添加","type":"1", "area":"600px;auto", "maxmin":"true"}'>
                            <i class="iconfont">&#xe649;</i> 添加
                        </button>-->
                        <button class="layui-btn layui-btn-small" onclick="add();">
                            <i class="iconfont">&#xe653;</i>添加
                        </button>
                        <button class="layui-btn layui-btn-small layui-btn-danger ajax-all" data-name="checkbox" data-params='{"url": "/education/admin/route/delete"}'>
                            <i class="iconfont">&#xe626;</i> 删除
                        </button>
                    </div>
                    <div id="list" class="layui-form"></div>

                    <div class="text-right" id="page"></div>
                </section>
            </div>
        </div>
    </div>
    <div class="add-subcat">
        <form class="layui-form layui-form-pane" action="/education/admin/route/save" id="form1">
            <input type="hidden" name="a.id">
            <div class="layui-form-item">
                <label class="layui-form-label">路线名称</label>
                <div class="layui-input-block">
                    <input type="text" name="a.routename" required jq-verify="required"  class="layui-input ">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">路线颜色</label>
                <div class="layui-input-block">
                    <input type="text" name="a.routecolor" value="" id="colorPicker"
                           required jq-verify="required"  class="layui-input jscolor">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">备注</label>
                <div class="layui-input-block">
                    <input type="text" name="a.routedesc" required jq-verify="required"  class="layui-input ">
                </div>
            </div>

            <!--<div class="layui-form-item">
                <label class="layui-form-label">排序</label>
                <div class="layui-input-inline">
                    <input type="number" name="a.ord" required jq-verify="required" jq-error="必须为数字" value="0"
                           class="layui-input ">
                </div>
            </div>
-->
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" jq-submit jq-filter="submit">立即提交</button>
                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                </div>
            </div>
        </form>
    </div>
</body>

<script id="list-tpl" type="text/html"
        data-params='{"url":"/education/admin/route","dataName":"couponData","pageid":"#page", "method":"post"}'>
    <table id="example" class="layui-table lay-even" data-name="couponData" data-tplid="list-tpl">
        <thead>
        <tr>
            <th width="30"><input type="checkbox" id="checkall" data-name="checkbox" lay-filter="check"
                                  lay-skin="primary"></th>
            <th>路线名称</th>
            <th>路线颜色</th>
            <th>备注</th>
            <!--<th width="80">排序</th>-->
            <th>添加时间</th>
            <th width="150">操作</th>
        </tr>
        </thead>
        <tbody>
        {{# layui.each(d.list, function(index, item){ }}
        <tr>
            <td><input type="checkbox" name="checkbox" value="{{ item.id}}" lay-skin="primary"></td>
            <td>{{ item.routename }} </td>
            <td><div style="width: 80px; height: 25px; background-color: #{{ item.routecolor }}"></div> </td>
            <td>{{ item.routedesc ||''}} </td>
            <!--<td>{{ item.ord || ''}} </td>-->
            <td>{{ item.createtime||'' }}</td>
            <td>
                <button class="layui-btn layui-btn-mini" onclick="viewDetail('{{item.id}}');">
                    <i class="iconfont">&#xe653;</i>编辑
                </button>
                <button class="layui-btn layui-btn-mini layui-btn-danger ajax"
                        data-list='{"key":"id={{ item.id}}","msg":true,"render":"true","action":"del"}'
                        data-params='{"url": "/education/admin/route/delete","data":"ids={{ item.id}}", "method":"post", "confirm":"true"}'>
                    <i class="iconfont">&#xe626;</i>删除
                </button></td>
            </td>
        </tr>
        {{# }); }}
        </tbody>

    </table>
</script>
<script src="../js/layui/layui.js"></script>
<script type="text/javascript" src="../js/lib/jquery-1.11.2.min.js"></script>
<script type="text/javascript" src="../js/lib/rest.js"></script>
<script type="text/javascript" src="map/res/jscolor.js"></script>
<!--#include file="common/version.html"-->
<script>
    layui.use('user_list');

    function add(){
        document.getElementById("form1").reset();
        $('#colorpicker').val('')
        $('#form1').attr('action', '/education/admin/route/save');
        var index = layer.open({
            shade:0,
            type: 1,
            zIndex:100,
            title:'添加',
            content: $('.add-subcat')
        });
    }

    function viewDetail(ids){
        var index = layer.open({
            shade:0,
            type: 1,
            zIndex:100,
            title:'编辑',
            content: $('.add-subcat')
        });
        //layer.full(index);
        $('#form1').attr('action', '/education/admin/route/update/' + ids);
        restGet('/education/admin/route/view/' + ids, null, $('#form1'), function(rs){
        })
    }

    function formatDate(date) {
        if(date == null){
            return '';
        }
        return date && date.substring(0, 10);
    }
</script>

</html>